package algotithm.weekendrace.leetcode227.test1;

import java.util.Arrays;


/**
 * @author zhouyanxiang
 * @Date 2021-02-2021/2/7-10:39
 */
public class Solution {

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {3,4,5,1,2};
        boolean check = solution.check(nums);
        System.out.println(check);
    }

    public boolean check(int[] nums) {
        int n = nums.length;
        int[] nums2 = nums.clone();
        Arrays.sort(nums2);
        for(int i = 0; i < n; i++) {
            boolean same = true;
            for(int j = 0; j < n; j++) {
                if(nums[j] != nums2[(i + j) % n]) {
                    same = false;
                    break;
                }
            }
            if(same) {
                return true;
            }
        }
        return false;
    }

}
